//
//  SPageBaseController.h
//  EasyRetail
//
//  Created by Samuel on 16/1/8.
//
//

#import <UIKit/UIKit.h>
@class SPageModel;
@protocol SPageDelegate;
@interface SPageBaseController : UIPageViewController
/**
 *  初始化
 *
 *  @param controller      需要展现在这个controller上
 *  @param firstController 加载的第一个controller
 *  @param array           对象数据数组
 */
+ (SPageBaseController*)shareSPageBaseController:(UIViewController *)controller
                              andFirstController:(UIViewController *)firstController
                                        andDatas:(NSMutableArray<SPageModel*>*)array;
/**
 *  代理
 */
@property (nonatomic, weak)NSObject<SPageDelegate> *sDelegate;
/**
 *  controller数据源
 */
@property (nonatomic, strong)NSMutableArray<SPageModel*> *dataArray;
/**
 *  当前显示的controller
 */
@property (nonatomic, strong)id nowController;
/**
 *  当前显示的controller的数据
 */
@property (nonatomic, strong)id nowControllerViewData;

/**
 *  重载数据
 */
- (void)reloadData;
/**
 *  跳转到某个view
 *
 *  @param index
 */
- (void)setThePageToIndex:(NSInteger)index;

@end

@interface SPageModel : NSObject

@property (nonatomic, assign)NSInteger sTag;

@property (nonatomic, strong)id object;

-(instancetype)initWithSPageModel:(SPageModel*)model;
@end

@protocol SPageDelegate <NSObject>

@required
/**
 *  获取需要加载的controller
 *
 *  @param controller self
 *  @param index      index
 *
 *  @return
 */
- (UIViewController *)SPageBaseController:(SPageBaseController *)controller viewForRowAtIndex:(NSInteger)index;

@optional
/**
 *  滚动结束，当前显示的页面
 *
 *  @param controller
 *  @param index
 */
- (void)SPageBaseController:(SPageBaseController *)controller didScrollRowAtIndex:(NSInteger)index andObject:(SPageModel*)object;
@end
